package cn.wolfcode.luowowo.controller;

import cn.wolfcode.luowowo.domain.Banner;
import cn.wolfcode.luowowo.service.IBannerService;
import cn.wolfcode.luowowo.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 首页5个图片
 */
@RestController
@RequestMapping("index")
public class IndexController {

    @Autowired
    private IBannerService bannerService;

    // 首页轮播广告(5个)
    @GetMapping("/banners/travel")
    public Object bannersTravel(){

        List<Banner> lists = bannerService.queryBanner(Banner.TYPE_TRAVEL);
        return JsonResult.success(lists);
    }

    // (左)旅游攻略推荐(1个广告)
    @GetMapping("/banners/strategy")
    public Object bannersStrategy(){

        List<Banner> lists = bannerService.queryBanner(Banner.TYPE_STRATEGY);
        // 要判断lists为null不
        return JsonResult.success(lists.get(0));
    }
}
